package com.sfh.cpc.home.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sfh.cpc.R;
import com.sfh.cpc.com.BaseAppContent;
import com.sfh.cpc.com.ImageLoaderEngine;
import com.sfh.cpc.com.entity.EMass;
import com.sfh.cpc.com.ui.VipLimit;

/**
 * 功能描述: TODO
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/8
 */
public class HomeMassAdapter extends BaseQuickAdapter<EMass, BaseViewHolder> {


    public HomeMassAdapter() {
        super(R.layout.home_mass_adapter);
    }

    @Override
    protected void convert(BaseViewHolder helper, EMass item) {

        helper.setText(R.id.tv_title, item.getMassTitle());
        helper.setText(R.id.tv_rq, item.getMassContent());
        helper.setVisible(R.id.iv_vip, TextUtils.equals("1", item.getNoteVip()));

        ImageView iv_image = helper.getView(R.id.iv_image);

        if (VipLimit.lookMass(item)){
            new ImageLoaderEngine(iv_image,  BaseAppContent.getImageUrl(item.getMassUrl())).
                    roundTransformCenterCrop(7).into(iv_image);
        }else{
            new ImageLoaderEngine(iv_image.getContext(), R.drawable.mentoring_top_adpic).roundTransformCenterCrop(7).into(iv_image);
        }
    }
}
